<!--
 * @Author: zqx me_zqx@163.com
 * @Date: 2025-07-02 10:01:47
 * @LastEditors: zqx me_zqx@163.com
 * @LastEditTime: 2025-07-02 15:01:19
 * @FilePath: /XMate-h5/src/views/myXmate/myTeam/teamNoticeBoard/index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="flex flex-col gap-4 bg-white">
    <van-sticky>
      <NoticeBoardHead
        v-model:mydprt="currentDept"
        v-model:activeIndex="activeIndex"
        :tabs="tabs"
        @dateChange="handleDateChange"
      />
    </van-sticky>
    <VisitSituation v-if="activeIndex === 0" />
    <SalesPerformance v-if="activeIndex === 1" />
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from "vue";
import VisitSituation from "./visitSituation/index.vue";
import SalesPerformance from "./salesPerformance/index.vue";
import NoticeBoardHead from "@/views/myXmate/components/noticeBoardHead.vue";
import { useMyXmateStore } from "@/store";
import { getDateRange, DateRangeType } from "@/utils/timeTool";
import { mapReportType } from "@/views/myXmate/myTeam/teamNoticeBoard/salesPerformance/typeAdaptor";

const tabs = [
  { text: "沟通情况", value: "visitSituation" },
  { text: "销售表现", value: "salesPerformance" }
];
const store = useMyXmateStore();

const activeIndex = ref(0);

function handleDateChange(v: DateRangeType) {
  const dateRange = getDateRange(v);
  if (!dateRange) {
    return;
  }
  store.noticeBoardPublicParam.startDate = dateRange?.startDate;
  store.noticeBoardPublicParam.endDate = dateRange?.endDate;
  store.noticeBoardPublicParam.reportType = mapReportType(v);

}

const currentDept = computed({
  get() {
    return store.noticeBoardPublicParam.currentDept;
  },
  set(v) {
    store.noticeBoardPublicParam.currentDept = v;
    store.generatedCandidateList([v.id]);
  }
});

</script>

<style scoped></style>
